package com.bdqn.xu.controller;

import com.bdqn.xu.pojo.Invitation;
import com.bdqn.xu.service.InvitationServers;
import com.bdqn.xu.service.Reply_detailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/invi")
public class InvitationController {
    @Resource
    private InvitationServers invitationServers;
    @Autowired
    private Reply_detailService reply_detailService;

    @RequestMapping("/getByid")
    public  String getDeptByid(Model model){
        Invitation invitation= invitationServers.getInvitationByid();
    model.addAttribute("invitation",invitation);
    return "main";
    }
    @RequestMapping("/getinvlist")
    public  String getinvlist(Model model){
        List<Invitation> inviList = invitationServers.getList();
        model.addAttribute("inviList",inviList);
        return "index";
    }
    @RequestMapping("/getlist")
    public String getlist(@RequestParam("title") String title, Model model){
        List<Invitation> inviList = invitationServers.likelist(title);
        model.addAttribute("inviList",inviList);
        return "index";
    }
    @RequestMapping("/del/{id}")
    public String delRE(@PathVariable Integer id){
        invitationServers.delReply(id);
        reply_detailService.delReply(id);
        return "redirect:/invi/getlist";
    }




}
